package task;

import java.io.Serializable;
import java.util.*;

public class Task implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -6000994645224658937L;
	/**
	 * 
	 */
	
	protected long id;
	protected String command;
	protected Vector<String> files;
	protected long owner; // Generatore del Task..
	
	public Task(long anId, String aCommand, Vector<String> aListOfFiles, long owner){
		super();
		
		id = anId;
		if(aCommand!=null)
			command = aCommand;
		else
			command = new String();
		
		if(aListOfFiles!=null)
			files = aListOfFiles;
		else
			files = new Vector<String>();
		
		this.owner = owner;
	}
	
	public Task(String aCommand, Vector<String> aListOfFiles, long owner)
	{
		super();
		this.id = Long.parseLong(String.valueOf(Thread.currentThread().getId()) + 
										String.valueOf(Calendar.getInstance().getTimeInMillis()));
		if(aCommand!=null)
			command = aCommand;
		else
			command = new String();
		
		if(aListOfFiles!=null)
			files = aListOfFiles;
		else
			files = new Vector<String>();
		
		this.owner = owner;
	}
	
	public long getId()
	{
		return this.id;
	}
	
	public String getCommand()
	{
		return this.command;
	}
	
	public Vector<String> getFiles()
	{
		return this.files;
	}
	
	
	public void setCommand(String newCommand)
	{
		command = newCommand;
	}
	
	public void setFiles(Vector<String> newFiles)
	{
		files = newFiles;
	}

	public long getOwner(){
		return this.owner;
	}
	
	public void setOwner(long newOwner)
	{
		this.owner = newOwner;
	}
	
	public String toString()
	{
		return "\n\tTASK ID: " + String.valueOf(this.id) + "\n\tCOMMAND: " + this.command;  
	}
	
}